package com.zsrt.java.day20161227.wrl.demo02;

import org.junit.Test;

public class RandomDemo02 {
	/**
	 * 1.首先把11个人放进去
	 * 2.随机random floor 取出来
	 * @throws Exception
	 */
	@Test
	public void random02() throws Exception {
		int len = 11;
		//"张泽谋","吴荣来","钟鹏","刘浩","谢文威","黄志杰","张志东","胡斌"，"陈皋","曾少华","林天杰"
		String[] class1612 = new String[len];
		class1612[0] = "张泽谋";
		class1612[1] = "吴荣来";
		class1612[2] = "钟鹏";
		class1612[3] = "刘浩";
		class1612[4] = "谢文威";
		class1612[5] = "黄志杰";
		class1612[6] = "张志东";
		class1612[7] = "胡斌";
		class1612[8] = "陈皋";
		class1612[9] = "曾少华";
		class1612[10] = "林天杰";
		
		int count = 20;
		while(count > 0){
			
			//获取随机数：Math.random():返回 0.0<=number<1.0 的随机数
			double ran = Math.random();
			int index = (int)Math.floor(ran*len);
			System.out.println(class1612[index]+" ： "+index);
			count--;
		}
		
	}
}
